ALTER             proc sp_get_board_inv_product_list

as
begin

declare @results Table(Part_Number varchar (20), ProcessStep_ID int, Process_Type varchar(20))
 

declare bcursor cursor for 
    select Part_Number,Process_Step.ProcessStep_ID, P_Type from product,Process_Step  where product.P_Type = 'BOARD' and product.p_parent_product_id = -1 and product.Is_Approved = 0 and product.ProcessStep_ID in (select processstep_id from Process_Step where PS_Type_Name like 'Finished Goods') and product.processStep_id=Process_Step.ProcessStep_ID order by product.Part_Number
declare @Part_Number varchar (20)
declare @p_id int
declare @p_type varchar (20)
insert into @results values('----BOARD------','','')

open bcursor
	fetch next from bcursor into @Part_Number,@p_id,@p_type
	while @@fetch_status = 0
	begin
		insert into @results values(@Part_Number,@p_id,@p_type)
		set @Part_Number = null
		set @p_id        = null
                set @p_type	 = null
		fetch next from bcursor into @Part_Number,@p_id,@p_type
	end
close bcursor 
deallocate bcursor 

insert into @results values('----KIT-------','','')
declare kcursor cursor for 
    select part_number,Process_Step.ProcessStep_ID, P_Type from product,Process_Step  where P_Type = 'KIT' and product.p_parent_product_id = -1 and product.Is_Approved = 0 and  product.ProcessStep_ID in (select processstep_id from Process_Step where PS_Type_Name like 'Mark & Pack' or PS_Type_Name like 'Finished Goods' or PS_Type_Name like 'Wafer Store' or PS_Type_Name like 'Die%' or PS_Type_Name like 'Class Store') and product.processStep_id=Process_Step.ProcessStep_ID order by product.part_number
open kcursor
	fetch next from kcursor into @Part_Number,@p_id,@p_type
	while @@fetch_status = 0
	begin
		insert into @results values(@Part_Number,@p_id,@p_type)
		set @Part_Number = null
		set @p_id        = null
                set @p_type	 = null
		fetch next from kcursor into @Part_Number,@p_id,@p_type
	end
close kcursor 
deallocate kcursor 
end

select Part_Number, ProcessStep_ID from @results
